<?php 
namespace app\admin\controller;
use app\common\controller\Base;
use app\common\model\Category as Cate;
use think\Request;
/**
 * @Author: YeMiao
 * @Date:   2017-08-01 10:00:34
 * @Last Modified by:   YeMiao
 * @Last Modified time: 2017-08-04 10:28:26
 */

class Category extends Base{

	public function index(){
		$category = new Cate();
		$list = $category->get_list();
		$this->assign('list',$list);		
		return $this->fetch();
	}

	public function category_add(){
		if(Request::instance()->isPost()){
			$category = new Cate();
			if(input('post.')){
				$add = $category->add_category(input('post.'));
				return $add;
			}else{
				$list = $category->get_f_list();
				$this->assign('list',$list);
				return $this->fetch();
			}			
		}	
	}

	public function category_del(){
		if(Request::instance()->isPost()){
			$category = new Cate();
			$del = $category->del_category(input('post.'));
			return $del;
		}
	}

	public function category_edit(){
		if(Request::instance()->isPost()){
			$category = new Cate();
			$find = $category->find_id(input('post.'));
			$find_f = $category->get_f_list();
			$this->assign('list',$find);
			$this->assign('flist',$find_f);
			return $this->fetch();
		}	
	}

	public function category_update(){
		if(Request::instance()->isPost()){
			$category = new Cate();
			$update = $category->update_category(input('post.'));
			return $update;
		}
	}

	public function category_update_show(){
		if(Request::instance()->isPost()){
			$category = new Cate();
			$update = $category->update_show_category(input('post.'));
			return $update;
		}	
	}
}

?>